POV-Ray : Newsgroups : povray.newusers : Question with a macro : Re: Question with a macro Server Time
29 Jul 2024 14:21:46 EDT (-0400)
  Re: Question with a macro  
From: Chris B
Date: 27 Sep 2005 17:26:38
Message: <4339b90e$1@news.povray.org>
"Oleguer Vilella" <ole### [at] infonegociocom> wrote in message 
news:43398e17@news.povray.org...
> Hi,
>
> I've this blob:
> ======================================
> #declare Lipid =
> blob {
>     threshold 0.5
> sphere {
>       <0, 5/2, 0>, 2/1.2, 1
>       texture { RedTexture }
>     }
>     sphere {
>       <0, -5/2, 0>, 2/1.2, 1
>       texture { RedTexture }
>     }
>     cylinder {
>       <0.8, 5/2, 0>, <0.8, -5/2, 0>, 0.5/1.2, 1
>       texture { WhiteTexture }
>     }
>     cylinder {
>       <-0.8, 5/2, 0>, <-0.8, -5/2, 0>, 0.5/1.2, 1
>       texture { WhiteTexture }
>     }
> translate <0, 0, 0>
> }
> ======================================
> And I've done a macro to place copies from this object and to put them 
> like a bridge. Now I want to put them like a sphere, I want to follow the 
> length of a sphere with a radius x.
> Is it a way to contain them in a sphere and follow the external contour?
>
> Thanks in advance,
> Oleguer
>

Hi Oleguer,

I'm not quite clear from your note on the sort of distribution you're trying 
for.

The following SDL produces an arc of 'Lipids' and rotates it 360 degrees to 
give a spherical surface with a separation of 20 degrees:

#declare Angle=20;
#declare Distance=30;
#local I=0;
#while (I<360)
  #local J=0;
  #while (J<180)
    object {Lipid translate z*Distance rotate <J,0,I> pigment {color 1}}
    #local J=J+Angle;
  #end
  #local I=I+Angle;
#end

If you want a more random distribution, then you can use something like the 
following:

#declare Distance=30;
#local I=0;
#local Seed = seed(1);
#while (I<30)
  object {Lipid
    rotate <rand(Seed)*360,rand(Seed)*360,rand(Seed)*360>   // Randomly 
Orient
//    translate z*Distance*sqrt(rand(Seed)) 
// Randomly Fill
    translate z*Distance 
// Distribute on Surface
    rotate <asind(sqrt(rand(Seed))),0,rand(Seed)*360>               // 
Randomly Distribute
    #if (rand(Seed)>0.5) scale <1,1,-1> #end
    pigment {color 1}
  }
  #local I=I+1;
#end
sphere {0,Distance pigment {color rgbt 0.95}}

The alternative 'translate', that's commented out, fills the sphere with 
your shape rather than just placing a copy on the surface.

If you want a random but uniform distribution then it gets a bit complicated 
and there have been quite a few threads discussing various alternative 
techniques for doing that.

Hope that helps.

Regards,
Chris B.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.